﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HotelManagement;
using HotelManagement.Account;
using HotelManagement.Customer;
using HotelManagement.Room;
using HotelManagement.BLO;
using HotelManagement.DTO;
using HotelManagement.Rent;
using HotelManagement.Services;
using HotelManagement.CheckOut;

namespace HotelManagement
{
    public partial class HotelManagementMainForm : Form
    {
        LoginForm frmLogin;
        private bool _state;//true la dang dang nhap
        private AccountBLO blo;
        private AccountDTO account;
        public static string _curUserName = "admin";

        public HotelManagementMainForm()
        {
            InitializeComponent();
            blo = new AccountBLO();
            account = new AccountDTO();
            this._state = true;
        }

        private void HotelManagement_Load(object sender, EventArgs e)
        {
            _authorize();
            //RoomManagement frmUser = new RoomManagement();
            //CustomerManagement frmUser = new CustomerManagement();
            //AccountManagement frmUser = new AccountManagement();
            //RentRoomManagement frmUser = new RentRoomManagement();
            ServiceManagement frmUser = new ServiceManagement();
            //CheckOutManagement frmUser = new CheckOutManagement();
            tabAccountManagement.Controls.Add(frmUser);
            frmUser.Enabled = true;
        }
        private void _authorize()
        {
            if (_state==false)
            {
                btnLogin.Text = "Đăng nhập";
            } 
            else
            {
                btnLogin.Text = "Đăng xuất";
            }
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            frmLogin = new LoginForm();
            if (DialogResult.OK == frmLogin.ShowDialog(this))
            {
                _state = true;
                this.account = blo.GetInformationOfAUser(_curUserName);
                this.txtUserName.Text = account.UserName;
                _authorize();
            }
        }

        
    }
}
